//
//  housecountTableViewCell.m
//  sellHouse
//
//  Created by 李 佳伟 on 2018/11/22.
//  Copyright © 2018年 李 佳伟. All rights reserved.
//

#import "housecountTableViewCell.h"
#import "JTCSM.h"
#import "HouserInfoModel.h"
#import "HouseZhexianModel.h"



@interface housecountTableViewCell ()
{
    UIView *keepview;
    UIView *daikanview;
    UIView *shoucangview;
    UIView *touchview;
    UILabel *sevenLabel;
    UIView *dataView;
}

@end
@implementation housecountTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [df lineViewWithHeightofTop:10 superView:self.contentView lineHeight:10 space:0];
        UILabel *titlelabel= [UILabel initWithFrame:CGRectMake(Kspace, 10, KSCREENWidth-2*Kspace, 50) text:@"平台统计" font:17 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(51, 51, 51, 1) backgroundColor:nil];
        [self.contentView addSubview:titlelabel];
       [df lineViewWithHeightofTop:60 superView:self.contentView lineHeight:1 space:Kspace];
        self.userInteractionEnabled = YES;
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(Kspace, KVIEW_Y(titlelabel)+10, KSCREENWidth-2*Kspace, 65)];
        [self.contentView addSubview:view];
        view.tag = 500;
        view.hidden =YES;
        view.userInteractionEnabled = YES;
        CGFloat labelwidth = view.frame.size.width/3;
        CGFloat labelheight = 14;
        CGFloat top = 12;
        CGFloat changespace = 11;
        
        _daikanLabel = [UILabel initWithFrame:CGRectMake(0, top, labelwidth, labelheight) text:@"123" font:12 textAlignment:NSTextAlignmentCenter texcolor:RGBACOLOR(48, 48, 48, 1) backgroundColor:nil];
        [view addSubview:_daikanLabel];
        [_daikanLabel setTag:301];
        
        
        UILabel *daikanbottomLabel = [UILabel initWithFrame:CGRectMake(0, KVIEW_Y(_daikanLabel)+changespace, labelwidth, labelheight) text:@"带看人数" font:14 textAlignment:NSTextAlignmentCenter texcolor:RGBACOLOR(153, 153, 153, 1) backgroundColor:nil];
        [view addSubview:daikanbottomLabel];
        
        
        _shoucangLabel = [UILabel initWithFrame:CGRectMake(labelwidth, top, labelwidth, labelheight) text:@"123" font:12 textAlignment:NSTextAlignmentCenter texcolor:RGBACOLOR(48, 48, 48, 1) backgroundColor:nil];
        [view addSubview:_shoucangLabel];
         [_shoucangLabel setTag:302];
        
        UILabel *shoucangbottomLabel = [UILabel initWithFrame:CGRectMake(labelwidth, KVIEW_Y(_daikanLabel)+changespace, labelwidth, labelheight) text:@"收藏人数" font:14 textAlignment:NSTextAlignmentCenter texcolor:RGBACOLOR(153, 153, 153, 1) backgroundColor:nil];
        [view addSubview:shoucangbottomLabel];
        
        _touchLabel = [UILabel initWithFrame:CGRectMake(labelwidth*2, top, labelwidth, labelheight) text:@"123" font:12 textAlignment:NSTextAlignmentCenter texcolor:RGBACOLOR(48, 48, 48, 1) backgroundColor:nil];
        [view addSubview:_touchLabel];
         [_touchLabel setTag:303];
        
        UILabel *touchbottomLabel = [UILabel initWithFrame:CGRectMake(labelwidth*2, KVIEW_Y(_daikanLabel)+changespace, labelwidth, labelheight) text:@"点击人数" font:14 textAlignment:NSTextAlignmentCenter texcolor:RGBACOLOR(153, 153, 153, 1) backgroundColor:nil];
        [view addSubview:touchbottomLabel];
        
        UIView *lineview= [df lineViewWithHeightofTop:KVIEW_Y(view) superView:self.contentView lineHeight:1 space:Kspace];
        lineview.tag=600;
        lineview.hidden = YES;
        sevenLabel = [UILabel initWithFrame:CGRectMake(0, KVIEW_Y(view)+22, KSCREENWidth, 15) text:@"近7日趋势" font:15 textAlignment:NSTextAlignmentCenter texcolor:RGBACOLOR(21, 21, 21, 1) backgroundColor:nil];
        sevenLabel.hidden = YES;
        [self.contentView addSubview:sevenLabel];
        
        
       
        CGRect rect = [df labelHeightWithContent:touchbottomLabel.text width:1000 font:14];
        
        CGFloat originX = (labelwidth-labelheight-4-rect.size.width)/2 ;
        
        daikanview = [[UIView alloc]initWithFrame:CGRectMake(originX+Kspace, KVIEW_Y(sevenLabel)+21, labelheight, labelheight)];
        daikanview.tag = 5000;
        daikanview.backgroundColor = RGBACOLOR(15,166,232,1);
        [df layerWithView:daikanview radius:labelheight/2 width:0 color:nil];
        [self.contentView addSubview:daikanview];
        self.onelabel= [UILabel initWithFrame:CGRectMake(KVIEW_X(daikanview)+8, KVIEW_Y(sevenLabel)+21, rect.size.width, labelheight) text:daikanbottomLabel.text font:14 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(153, 153, 153, 1) backgroundColor:nil];
        [self.contentView addSubview: self.onelabel];
        self.onelabel.userInteractionEnabled=YES;
        
        shoucangview = [[UIView alloc]initWithFrame:CGRectMake(Kspace+labelwidth+originX, KVIEW_Y(sevenLabel)+21, labelheight, labelheight)];
        shoucangview.tag = 5001;
        shoucangview.backgroundColor = RGBACOLOR(255, 135, 38, 1);
        [df layerWithView:shoucangview radius:labelheight/2 width:0 color:nil];
        [self.contentView addSubview:shoucangview];
         self.twolabel = [UILabel initWithFrame:CGRectMake(KVIEW_X(shoucangview)+8, KVIEW_Y(sevenLabel)+21, rect.size.width, labelheight) text:shoucangbottomLabel.text font:14 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(153, 153, 153, 1) backgroundColor:nil];
        [self.contentView addSubview:self.twolabel];
        self.twolabel.userInteractionEnabled=YES;
        
        touchview = [[UIView alloc]initWithFrame:CGRectMake(Kspace+labelwidth*2+originX, KVIEW_Y(sevenLabel)+21, labelheight, labelheight)];
        touchview.tag = 5002;
        touchview.backgroundColor = RGBACOLOR(241, 124, 202, 1);
        [df layerWithView:touchview radius:labelheight/2 width:0 color:nil];
        [self.contentView addSubview:touchview];
        self.threelabel = [UILabel initWithFrame:CGRectMake(KVIEW_X(touchview)+8, KVIEW_Y(sevenLabel)+21, rect.size.width, labelheight) text:touchbottomLabel.text font:14 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(153, 153, 153, 1) backgroundColor:nil];
        [self.contentView addSubview:self.threelabel];
        self.threelabel.userInteractionEnabled = YES;
        self.userInteractionEnabled = YES;
        self.contentView.userInteractionEnabled = YES;
        self.zhexianview = [[zhexianTuView alloc]initWithFrame:CGRectMake(0, KVIEW_Y(self.threelabel)+30, KSCREENWidth, 100) withDatalist:nil];
        [self.contentView addSubview:self.zhexianview];
        [df lineViewWithHeightofTop:KVIEW_X(self.zhexianview) superView:self.contentView lineHeight:30 space:0].backgroundColor = [UIColor whiteColor];
        
        dataView = [[UIView alloc]initWithFrame:CGRectMake(0, KVIEW_Y(titlelabel)+40, KSCREENWidth, 120)];
        dataView.hidden = YES;
        [self.contentView addSubview:dataView];
        CGFloat images = 90;
        UIImageView *imageV1= [[UIImageView alloc]initWithFrame:CGRectMake((KSCREENWidth-images)/2, 0, images, images)];
        imageV1.image  = [UIImage imageNamed:@"datanull.jpg"];
        [dataView addSubview:imageV1];
        
        UILabel *label = [UILabel initWithFrame:CGRectMake(0, KVIEW_Y(imageV1)+20, KSCREENWidth, 30) text:@"暂无平台统计数据哦" font:15 textAlignment:NSTextAlignmentCenter texcolor:RGBACOLOR(151, 151, 151, 1) backgroundColor:nil];
        label.tag = 6025639;
        [dataView addSubview:label];
        
    }
    
    return self;
}

- (void)setvalueWithModel:(id)model{
    HouserInfoModel *mymodel = model;
    
    UIView *view = [self.contentView viewWithTag:500];
    view.hidden = NO;
    UIView *view1 = [self.contentView viewWithTag:600];
    view1.hidden = NO;
    sevenLabel.hidden = NO;
    _daikanLabel.text = [NSString stringWithFormat:@"%@",mymodel.takeCount];
    _shoucangLabel.text =  [NSString stringWithFormat:@"%@",mymodel.collectCount];
    _touchLabel.text =  [NSString stringWithFormat:@"%@",mymodel.clickCount];
}

- (void)setzhexianWithmodel:(id)model{
    HouseZhexianModel *mymodel = model;
    _zhexianview = nil;
    [_zhexianview removeFromSuperview];
    if (mymodel.isShow) {
        dataView.hidden = YES;
        daikanview.hidden = NO;
        shoucangview.hidden = NO;
        touchview.hidden = NO;
        _onelabel.hidden = NO;
        _twolabel.hidden = NO;
        _threelabel.hidden = NO;
        _zhexianview.hidden = NO;
        self.zhexianview = [[zhexianTuView alloc]initWithFrame:CGRectMake(0, KVIEW_Y(self.threelabel)+30, KSCREENWidth, 100) withDatalist:mymodel];
        [self.contentView addSubview:self.zhexianview];
        [self.zhexianview dravLineWithType:DAIKAN_TYPE datasource:mymodel.takeCount.mutableCopy];
        
        [self.zhexianview dravLineWithType:SHOCANG_TYPE datasource:mymodel.collectCount.mutableCopy];
        
        [self.zhexianview dravLineWithType:TOUCH_TYPE datasource:mymodel.clickCount.mutableCopy];
    }else{
       dataView.hidden = NO;
        UIView *view = [self.contentView viewWithTag:500];
        view.hidden = YES;
        UIView *view1 = [self.contentView viewWithTag:600];
        view1.hidden = YES;
        sevenLabel.hidden = YES;
        daikanview.hidden = YES;
        shoucangview.hidden = YES;
        touchview.hidden = YES;
        _onelabel.hidden = YES;
        _twolabel.hidden = YES;
        _threelabel.hidden = YES;
        _zhexianview.hidden = YES;
        
    }
   
}

@end
